//
//  RGDescriptionView.m
//  RedGrass
//
//  Created by wukong on 2018/12/10.
//  Copyright © 2018年 hongcaosp. All rights reserved.
//

#import "RGDescriptionView.h"

@interface RGDescriptionView()

@property (strong, nonatomic) UILabel *userNameLabel;
@property (strong, nonatomic) UILabel *desLabel;


@end

@implementation RGDescriptionView

-(instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        [self addSubview:self.userNameLabel];
        [self addSubview:self.desLabel];
        [self addMasonry];
    }
    return self;
}

-(void) addMasonry{
    [_userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).mas_offset(20);
        make.top.mas_equalTo(self).mas_offset(4);
        make.right.mas_equalTo(self).mas_offset(-8);
    }];
    
    [_desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).mas_offset(20);
        make.top.mas_equalTo(self.userNameLabel.mas_bottom).mas_offset(10);
        make.right.mas_equalTo(self).mas_offset(-8);
        make.bottom.lessThanOrEqualTo(self).mas_offset(-8);
    }];
}

#pragma mark - public

-(void) resetView{
    _userNameLabel.text = @"";
    _desLabel.text = @"";
}

-(void) updateUserName:(NSString *)userName userDes:(NSString *)userDes{
    _userNameLabel.text = [NSString stringWithFormat:@"@%@",SafeStr(userName)];
    _desLabel.text = SafeStr(userDes);
}

#pragma mark - getter

-(UILabel *)userNameLabel{
    if(!_userNameLabel){
        _userNameLabel = [[UILabel alloc]init];
        _userNameLabel.textColor = [UIColor whiteColor];
        _userNameLabel.font = FONT(customBoldFontName, FFont_16);
        _userNameLabel.text = @"@用户名";
    }
    return _userNameLabel;
}

-(UILabel *)desLabel{
    if(!_desLabel){
        _desLabel = [[UILabel alloc]init];
        _desLabel.textColor = [UIColor whiteColor];
        _desLabel.font = FONT(customFontName, FFont_14);
        _desLabel.text = @"test";
        _desLabel.numberOfLines = 3;
    }
    return _desLabel;
}


@end
